package com.example.medical.controller.leadership;

import com.example.medical.entity.dto.LeadershipGetUserListDto;
import com.example.medical.service.UserService;
import com.example.medical.utils.common.enums.Code;
import com.example.medical.utils.common.result.Result;
import com.example.medical.utils.config.BaseContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/leadership/")
public class LeadershipUserController {

    @Autowired
    private UserService userService;

    @PostMapping("get_user_list")
    public Result LeadershipGetUserList(@RequestBody LeadershipGetUserListDto dto){
        return userService.LeadershipGetUserList(dto);
    }

    @GetMapping("/get_user_detail")
    public Result LeadershipGetUserDetail(@RequestParam("id") Long id){
        if (BaseContext.getCurrentId()==null) {
            return Result.errorResult(Code.NEED_LOGIN);
        }
        return Result.okResult(userService.getById(id));
    }

}
